

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  
    <meta name="description" content="参考资料 视频资料 运行环境  windows10 CentOS 7 虚拟机 JDK8 Hadoop3.1.3 3个集群节点  一、集群的不同启动方式 1.1 各模块分开启动（常用）（1）各个模块分开启动&#x2F;停止（配置ssh是前提）常用  整体启动&#x2F;停止 HDFS1start-dfs.sh&#x2F;stop-dfs.sh （2）整体启动&#x2F;停止YARN1start-yarn.sh">
<meta property="og:type" content="article">
<meta property="og:title" content="Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本">
<meta property="og:url" content="http://example.com/2022/01/16/Hadoop%20_%20%E9%9B%86%E7%BE%A4%E9%85%8D%E7%BD%AE%EF%BC%88%E5%9B%9B%EF%BC%89%E5%90%AF%E5%8A%A8%E6%B5%8B%E8%AF%95%E5%AE%8C%E5%85%A8%E5%88%86%E5%B8%83%E5%BC%8F%E9%9B%86%E7%BE%A4%20_%20%E7%BC%96%E5%86%99%20Shell%20%E8%84%9A%E6%9C%AC%E4%B8%80%E9%94%AE%E5%90%AF%E5%8A%A8%E9%9B%86%E7%BE%A4%20_%20Hadoop%20%E9%9B%86%E7%BE%A4%E5%B8%B8%E7%94%A8%E8%84%9A%E6%9C%AC/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="参考资料 视频资料 运行环境  windows10 CentOS 7 虚拟机 JDK8 Hadoop3.1.3 3个集群节点  一、集群的不同启动方式 1.1 各模块分开启动（常用）（1）各个模块分开启动&#x2F;停止（配置ssh是前提）常用  整体启动&#x2F;停止 HDFS1start-dfs.sh&#x2F;stop-dfs.sh （2）整体启动&#x2F;停止YARN1start-yarn.sh">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/3de9a3884d6e465289bcf19530c5bf82.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/b5c33ed2c2af4ac785f9079c8f8d40fc.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/275d6f9358ee44f1b9147c369af82c39.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/7e586bda4b7b406189b2d513a02b6206.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/d46c89e989bf421e8714eb68f4c00f73.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/6e55c6b5afe3494cb60d9289e36a9987.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/7c90f6296c374b29876137ba7b5e7b3b.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/33936678ac7c4061a771f463035dad92.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/c454be9c35094e7ebfe1a3823479c577.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/3756290e92bb4e74883e8e836e22c9a8.png#pic_center">
<meta property="og:image" content="https://img-blog.csdnimg.cn/34acebf19eac44d09f42da6d6b26d954.png">
<meta property="article:published_time" content="2022-01-16T11:43:34.000Z">
<meta property="article:modified_time" content="2022-08-22T15:43:51.274Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="Hadoop">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/3de9a3884d6e465289bcf19530c5bf82.png#pic_center">
  
  
  
  <title>Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>尤 Ni&#39;s Blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        John Doe
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-01-16 19:43" pubdate>
          2022年1月16日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          5.4k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          45 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：1 小时前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><hr>
<p><a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Qp4y1n7EN?p=35&spm_id_from=pageDriver">视频资料</a></p>
<h1 id="运行环境"><a href="#运行环境" class="headerlink" title="运行环境"></a>运行环境</h1><hr>
<ul>
<li>windows10</li>
<li>CentOS 7 虚拟机</li>
<li>JDK8</li>
<li>Hadoop3.1.3</li>
<li>3个集群节点</li>
</ul>
<h1 id="一、集群的不同启动方式"><a href="#一、集群的不同启动方式" class="headerlink" title="一、集群的不同启动方式"></a>一、集群的不同启动方式</h1><hr>
<h2 id="1-1-各模块分开启动（常用）"><a href="#1-1-各模块分开启动（常用）" class="headerlink" title="1.1 各模块分开启动（常用）"></a>1.1 各模块分开启动（常用）</h2><p>（1）各个模块分开启动&#x2F;停止（配置ssh是前提）常用</p>
<ul>
<li>整体启动&#x2F;停止 <code>HDFS</code><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">start-dfs.sh/stop-dfs.sh<br></code></pre></td></tr></table></figure>
（2）整体启动&#x2F;停止<code>YARN</code><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">start-yarn.sh/stop-yarn.sh<br></code></pre></td></tr></table></figure></li>
</ul>
<h2 id="1-2-各个服务组件逐一启动-x2F-停止"><a href="#1-2-各个服务组件逐一启动-x2F-停止" class="headerlink" title="1.2 各个服务组件逐一启动&#x2F;停止"></a>1.2 各个服务组件逐一启动&#x2F;停止</h2><p>（1）分别启动&#x2F;停止HDFS组件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">hdfs --daemon start/stop namenode/datanode/secondarynamenode<br></code></pre></td></tr></table></figure>
<p>（2）启动&#x2F;停止YARN</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">yarn --daemon start/stop  resourcemanager/nodemanager<br></code></pre></td></tr></table></figure>

<h1 id="二、启动Hadoop集群"><a href="#二、启动Hadoop集群" class="headerlink" title="二、启动Hadoop集群"></a>二、启动Hadoop集群</h1><p>基于上一篇文章记录：<a target="_blank" rel="noopener" href="https://blog.csdn.net/Unirithe/article/details/122521799">Hadoop | 集群配置（三）| 完全分布式集群规划 | 配置详情</a> ，现进行集群的启动测试，首先回顾一下集群中各节点的角色：</p>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="left">hadoop101</th>
<th align="left">hadoop102</th>
<th align="left">hadoop103</th>
</tr>
</thead>
<tbody><tr>
<td align="left">HDFS</td>
<td align="left">NameNode、DataNode</td>
<td align="left">DataNode</td>
<td align="left">SecondaryNameNode</td>
</tr>
<tr>
<td align="left">YARN</td>
<td align="left">NodeManager</td>
<td align="left">ResourceManager 、NodeManager</td>
<td align="left">NodeManager</td>
</tr>
</tbody></table>
<p>现在进行集群测试</p>
<h2 id="2-1-配置Hadoop的系统环境变量"><a href="#2-1-配置Hadoop的系统环境变量" class="headerlink" title="2.1 配置Hadoop的系统环境变量"></a>2.1 配置Hadoop的系统环境变量</h2><p>配置系统环境变量的目的是为了能在<strong>任何位置</strong>使用到所配置目录下的一些命令，同时在hadoop生态中也有些程序会用到环境变量，通常以<code>xxx_HOME</code>的形式，首先需要定义全局的变量，然后在赋值给<code>PATH</code>系统变量。</p>
<p>接下来是配置的命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">vim /etc/profile.d/home.sh<br></code></pre></td></tr></table></figure>
<p>配置的内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_">#</span><span class="language-bash">JDK8</span> <br>export JAVA_HOME=/opt/java/jdk8<br>export PATH=$PATH:$JAVA_HOME/bin/<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">Hadoop 3.1.3</span><br>export HADOOP_HOME=/opt/module/hadoop<br>export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin<br></code></pre></td></tr></table></figure>

<p>接着 <code>:wq</code> 保存退出，使配置文件生效的命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">source /etc/profile<br></code></pre></td></tr></table></figure>
<p>配置完成后就可以在任意位置使用<code>hadoop</code>目录下<code>sbin</code>和<code>bin</code>文件里的命令了。</p>
<p>集群中的其他所有节点也需要配置环境变量，这里可以使用之前设置的分发脚本<a target="_blank" rel="noopener" href="https://blog.csdn.net/Unirithe/article/details/122514706">[参考]</a>实现</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">xsync /etc/profil.d/home.sh<br></code></pre></td></tr></table></figure>
<p>但是分发过后仍然需要手动执行 <code>source /etc/profile</code> 才行</p>
<h2 id="2-2-初始化名称节点"><a href="#2-2-初始化名称节点" class="headerlink" title="2.2 初始化名称节点"></a>2.2 初始化名称节点</h2><p>这一步只在安装配置好Hadoop后首次执行，且 <strong>只执行一次</strong>。</p>
<p>在 <code>NameNode </code>（hadoop101）所在的节点执行下面的命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">hdfs namenode -format<br></code></pre></td></tr></table></figure>
<p>执行完毕后会在配置的namenode存储目录里生成一些文件<br>比如有一个<code>current</code>文件夹，里面会有一个<code>VERSION</code>文件用来表示当前节点的一些信息<br>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/b7857d07b966498dbc09cc96985071cb.png#pic_center#">https://img-blog.csdnimg.cn/b7857d07b966498dbc09cc96985071cb.png#pic_center#</a> &#x3D;60%x)</p>
<h2 id="2-3-启动-HDFS"><a href="#2-3-启动-HDFS" class="headerlink" title="2.3 启动 HDFS"></a>2.3 启动 HDFS</h2><p>HDFS 是一种分布式文件系统。</p>
<p>启动 HDFS 只需要在 NameNode 节点执行一次，集群中的其他节点会随时启动，前提是配置好SSH</p>
<p>命令是在sbin的目录下，由于配置过环境变量所以可以直接运行。<br>在<code>hdfs-site.xml</code>里配置的<code>namenode</code>节点（<strong>hadoop101</strong>）里启动hdfs</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">start-dfs.sh<br></code></pre></td></tr></table></figure>

<p>启动后可在各节点输入 <code>jps</code>命令查看启动的进程</p>
<figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">为什么是<span class="hljs-keyword">jps命令？jps命令的作用是类似于Linux的ps命令显示进程，jps只显示所有Java应用程序的进程</span><br><span class="hljs-keyword"></span><br>Hadoop的底层是使用<span class="hljs-keyword">Java语言实现的，所以Hadoop的运行需要有JDK环境，最开始配置了JDK8。</span><br><span class="hljs-keyword"></span><br>Hadoop启动时就相当于启动了一个<span class="hljs-keyword">Java应用程序，故可通过jps命令查看进程。</span><br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/3de9a3884d6e465289bcf19530c5bf82.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="2-4-启动-YARN"><a href="#2-4-启动-YARN" class="headerlink" title="2.4 启动 YARN"></a>2.4 启动 YARN</h2><p>YARN是资源调度管理器，是从hadoop2.x版本推行的。</p>
<p>在 <code>yarn-site.xml</code>配置文件里指定的<code>ResourceManager</code>节点（<strong>hadoop102</strong>）里启动 yarn</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">start-yarn.sh<br></code></pre></td></tr></table></figure>

<p><img src="https://img-blog.csdnimg.cn/b5c33ed2c2af4ac785f9079c8f8d40fc.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="2-5-启动MapReduce历史服务器"><a href="#2-5-启动MapReduce历史服务器" class="headerlink" title="2.5 启动MapReduce历史服务器"></a>2.5 启动MapReduce历史服务器</h2><p>MapReduce历史服务器的作用是记录每一次执行的mapreduce任务的一些资源消耗，需要手动开启，关闭的话将命令里的start替换成stop即可</p>
<p>这条命令需要在<code>mapred-site.xml</code>配置文件里指定的历史服务器节点来执行，比如笔者的配置是：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;?xml version=<span class="hljs-string">&quot;1.0&quot;</span> encoding=<span class="hljs-string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="hljs-meta">&lt;?xml-stylesheet type=<span class="hljs-string">&quot;text/xsl&quot;</span> href=<span class="hljs-string">&quot;configuration.xsl&quot;</span>?&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br>	<span class="hljs-comment">&lt;!-- 指定MapReduce程序运行在Yarn上 --&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.framework.name<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>yarn<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.jobhistory.address<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>hadoop102:10020<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.jobhistory.webapp.address<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>hadoop102:19888<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br><br></code></pre></td></tr></table></figure>

<p>在hadoop102节点上执行下面的命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">mapred --daemon start historyserver<br></code></pre></td></tr></table></figure>
<p>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/6885b58cf30142f5b43ff192b6424995.png#">https://img-blog.csdnimg.cn/6885b58cf30142f5b43ff192b6424995.png#</a> &#x3D;80%x)<br>至此，整个集群环境已经启动完毕接下来进行测试。</p>
<h1 id="三、集群测试"><a href="#三、集群测试" class="headerlink" title="三、集群测试"></a>三、集群测试</h1><hr>
<h2 id="3-1-测试-HDFS-命令"><a href="#3-1-测试-HDFS-命令" class="headerlink" title="3.1 测试 HDFS 命令"></a>3.1 测试 HDFS 命令</h2><p>在集群的任何节点都可以执行的命令</p>
<p>先准备一个文本，用于之后的词频统计测试，文本内容 test.txt：</p>
<figure class="highlight vbnet"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs vbnet">I <span class="hljs-built_in">like</span> sleep.<br>But sleep don<span class="hljs-comment">&#x27;t like me.</span><br>Hadoop <span class="hljs-built_in">is</span> hard <span class="hljs-keyword">to</span> learn.<br></code></pre></td></tr></table></figure>

<p>使用HDFS创建目录并上传本地文件到HDFS的命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">在HDFS里创建目录</span><br>hdfs dfs -mkdir -p /input<br><span class="hljs-meta prompt_"># </span><span class="language-bash">上传本地文件到HDFS</span><br>hdfs dfs -put ./test.txt /input<br><span class="hljs-meta prompt_"># </span><span class="language-bash">查看上传的结果</span><br>hdfs dfs -cat /input/test.txt<br></code></pre></td></tr></table></figure>

<p>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/64255244a35443aea71aa0b2dfec8372.png#">https://img-blog.csdnimg.cn/64255244a35443aea71aa0b2dfec8372.png#</a> &#x3D;80%x)</p>
<h2 id="3-2-访问-NameNode-的-Web页面"><a href="#3-2-访问-NameNode-的-Web页面" class="headerlink" title="3.2 访问 NameNode 的 Web页面"></a>3.2 访问 NameNode 的 Web页面</h2><p>这个是在 <code>hdfs-site.xml</code>配置文件里面指定的：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>     <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>dfs.namenode.http-address<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>     <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>hadoop101:9870<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p>访问地址：<a target="_blank" rel="noopener" href="http://hadoop101:9870/">http://hadoop101:9870</a></p>
<p>提示：若访问不到可以尝试在hadoop101输入<code>ifconfig</code>命令查看IP地址，然后通过IP访问。</p>
<p><img src="https://img-blog.csdnimg.cn/275d6f9358ee44f1b9147c369af82c39.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>比较有趣的是这个web网站是使用bootstrap3框架搭建的<br><img src="https://img-blog.csdnimg.cn/7e586bda4b7b406189b2d513a02b6206.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>笔者暗自窃喜，因为上学期在web课程花了很多时间去使用bootstrap框架进行页面设计。</p>
<h2 id="3-3-访问YARN中ResourceManager的-Web-页面"><a href="#3-3-访问YARN中ResourceManager的-Web-页面" class="headerlink" title="3.3 访问YARN中ResourceManager的 Web 页面"></a>3.3 访问YARN中ResourceManager的 Web 页面</h2><p>这个是在 <code>yarn-site.xml</code>里指定的，若没有指定则是默认的，笔者没有指定，官方<a target="_blank" rel="noopener" href="https://gitee.com/ccuni/hadoop-learn/blob/master/hadoop3.1.3-default-config/yarn-default.xml">[yarn-default.xml]</a>默认的配置如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>yarn.resourcemanager.webapp.address<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>hadoop102:8088<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p>访问地址：<a target="_blank" rel="noopener" href="http://hadoop102:8088/">http://hadoop102:8088</a></p>
<p><img src="https://img-blog.csdnimg.cn/d46c89e989bf421e8714eb68f4c00f73.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>这时候还没有执行任何MapReduce任务，所以YARN ResourceManager访问端是空的。</p>
<h2 id="3-4-执行词频统计的分布式实例"><a href="#3-4-执行词频统计的分布式实例" class="headerlink" title="3.4 执行词频统计的分布式实例"></a>3.4 执行词频统计的分布式实例</h2><p>使用官方提供的 <code>hadoop-mapreduce-examples-3.1.3.jar</code>包去测试词频统计的结果，这个jar包实现的功能就是词频统计，使用时候需传入两个参数，第一个参数是HDFS里词频统计的文本，第二个参数是词频统计结果在HDFS的保存位置。</p>
<p>在集群里的任一节点执行下面的命令，以<code>hadoop101</code>为例：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd $HADOOP_HOME<br><br>hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount /input /output<br></code></pre></td></tr></table></figure>
<p>运行结果：<br><img src="https://img-blog.csdnimg.cn/6e55c6b5afe3494cb60d9289e36a9987.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>接下来使用 HDFS 命令查看并输出结果内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">hdfs dfs -ls /output<br><br>hdfs dfs -cat /output/*<br></code></pre></td></tr></table></figure>

<p><img src="https://img-blog.csdnimg.cn/7c90f6296c374b29876137ba7b5e7b3b.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>接着可以在 web端 查看到这一次的MapReduce执行记录<br>访问YARN ResourceManager的web端，地址为：<a target="_blank" rel="noopener" href="http://hadoop102:8080/">http://hadoop102:8080</a></p>
<p><img src="https://img-blog.csdnimg.cn/33936678ac7c4061a771f463035dad92.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>查看 <code>log </code>日志<br><img src="https://img-blog.csdnimg.cn/c454be9c35094e7ebfe1a3823479c577.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/3756290e92bb4e74883e8e836e22c9a8.png#pic_center" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h1 id="四、使用Shell脚本"><a href="#四、使用Shell脚本" class="headerlink" title="四、使用Shell脚本"></a>四、使用Shell脚本</h1><h2 id="4-1-集群启停脚本"><a href="#4-1-集群启停脚本" class="headerlink" title="4.1 集群启停脚本"></a>4.1 集群启停脚本</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">sudo vim /bin/hd.sh<br></code></pre></td></tr></table></figure>
<p>脚本内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_">#</span><span class="language-bash">! /bin/bash</span><br>if [ $# -lt 1 ]<br>then<br>    echo &quot;No Args Input...&quot;<br>    exit ;<br>fi<br>case $1 in<br>&quot;start&quot;)<br>        echo &quot; =================== START Hadoop Cluster ===================&quot;<br><br>        echo &quot; --------------- START hdfs ---------------&quot;<br>        ssh hadoop101 &quot;start-dfs.sh&quot;<br>        echo &quot; --------------- START yarn ---------------&quot;<br>        ssh hadoop102 &quot;start-yarn.sh&quot;<br>        echo &quot; --------------- START historyserver ---------------&quot;<br>        ssh hadoop102 &quot;mapred --daemon start historyserver&quot;<br>        ssh hadoop101<br>;;<br>&quot;stop&quot;)<br>        echo &quot; =================== START Hadoop Cluster ===================&quot;<br><br>        echo &quot; --------------- STOP historyserver ---------------&quot;<br>        ssh hadoop102 &quot;mapred --daemon stop historyserver&quot;<br>        echo &quot; --------------- STOP yarn ---------------&quot;<br>        ssh hadoop102 &quot;stop-yarn.sh&quot;<br>        echo &quot; --------------- STOP hdfs ---------------&quot;<br>        ssh hadoop101 &quot;stop-dfs.sh&quot;<br>;;<br>*)<br>    echo &quot;Input Args Error...&quot;<br>;;<br></code></pre></td></tr></table></figure>
<p>赋予脚本可执行权限：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">sudo chmod 777 /bin/hd.sh<br></code></pre></td></tr></table></figure>

<p><strong>使用脚本启动集群：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">hd.sh start<br></code></pre></td></tr></table></figure>

<p><strong>关闭集群：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">hd.sh stop<br></code></pre></td></tr></table></figure>

<h2 id="4-2-所有集群节点同步命令"><a href="#4-2-所有集群节点同步命令" class="headerlink" title="4.2 所有集群节点同步命令"></a>4.2 所有集群节点同步命令</h2><p><code>xcall.sh</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_">#</span><span class="language-bash">! /bin/bash</span><br><br>for i in hadoop101 hadoop102 hadoop103<br>do<br>    echo -------- $i ---------<br>    ssh $i &quot;$*&quot;<br>done<br></code></pre></td></tr></table></figure>

<p>查看所有集群节点的java进程状态：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">xcall.sh jps<br></code></pre></td></tr></table></figure>

<p><img src="https://img-blog.csdnimg.cn/34acebf19eac44d09f42da6d6b26d954.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E5%A4%A7%E6%95%B0%E6%8D%AE/" class="category-chain-item">大数据</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/Hadoop/">#Hadoop</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本</div>
      <div>http://example.com/2022/01/16/Hadoop _ 集群配置（四）启动测试完全分布式集群 _ 编写 Shell 脚本一键启动集群 _ Hadoop 集群常用脚本/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>John Doe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年1月16日</div>
        </div>
      
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/01/17/Hadoop%20_%20MapReduce%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0%20_%20JavaAPI%E6%9B%B4%E6%8D%A2%E5%88%87%E7%89%87%E6%9C%BA%E5%88%B6%20_%20CombineTextInputFormat%20%E5%88%87%E7%89%87%20_%20%E8%AF%8D%E9%A2%91%E7%BB%9F%E8%AE%A1%E6%A1%88%E4%BE%8B/" title="Hadoop _ HDFS学习笔记（一）HDFS优缺点、NN+DN+2NN组成架构、block文件块 _ Shell操作 _ HDFS常用命令汇总">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Hadoop _ HDFS学习笔记（一）HDFS优缺点、NN+DN+2NN组成架构、block文件块 _ Shell操作 _ HDFS常用命令汇总</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/01/16/MyBatis%20%E7%AC%94%E8%AE%B03%20%E5%8A%A8%E6%80%81SQL%E8%AF%AD%E5%8F%A5%20_%20trim%E6%A0%87%E7%AD%BE%E3%80%81foreach%E6%A0%87%E7%AD%BE%E3%80%81choose%E6%A0%87%E7%AD%BE%20_%20MyBatis%E7%BC%93%E5%AD%98%E6%9C%BA%E5%88%B6%20_%20MyBatis%20%E9%80%86%E5%90%91%E5%B7%A5%E7%A8%8B%E4%BD%BF%E7%94%A8%E6%A1%88%E4%BE%8B/" title="MyBatis 笔记3 动态SQL语句 _ trim标签、foreach标签、choose标签 _ MyBatis缓存机制 _ MyBatis 逆向工程使用案例">
                        <span class="hidden-mobile">MyBatis 笔记3 动态SQL语句 _ trim标签、foreach标签、choose标签 _ MyBatis缓存机制 _ MyBatis 逆向工程使用案例</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
